package com.example.a16478095_;

import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

public class orderMenu extends AppCompatActivity {
    private Food whr,hszt,lhxy,jc,pg,xcr;
    private CheckBox cb_whr,cb_hszt,cb_lhxy,cb_jc,cb_pg,cb_xcr;
    private  int totalPrice=0;
    private Button submit;
    private CheapCard c1,c2;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.menu);
        init();
        addPrice();
    }
    public void init(){
        whr = new Food("五花肉",30);
        hszt = new Food("红烧猪蹄",25);
        lhxy = new Food("莲花血鸭",20);
        jc = new Food("鸡翅",40);
        pg = new Food("排骨",40);
        xcr = new Food("小炒肉",20);
        c1 = new CheapCard("1111111",0.8);
        c2 = new CheapCard("8788888",0.6);

    }
    public void addPrice() {
        cb_whr = findViewById(R.id.cb_whr);
        cb_hszt = findViewById(R.id.cb_hszt);
        cb_lhxy = findViewById(R.id.cb_lhxy);
        cb_jc = findViewById(R.id.cb_jc);
        cb_pg = findViewById(R.id.cb_pg);
        cb_xcr = findViewById(R.id.cb_xcr);
        submit = findViewById(R.id.button);
        submit.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View view) {
                if(cb_whr.isChecked())
                    totalPrice +=30;
                if(cb_hszt.isChecked())
                    totalPrice +=25;
                if(cb_lhxy.isChecked())
                    totalPrice +=20;
                if(cb_jc.isChecked())
                    totalPrice +=17;
                if(cb_pg.isChecked())
                    totalPrice +=40;
                if(cb_xcr.isChecked())
                    totalPrice +=20;
            }
        });

    }

}
